<script lang="ts" setup>
import { useVbenModal } from '@vben/common-ui';






import { defineProps, defineAsyncComponent, ref, watch } from 'vue';

// const props = defineProps<{
//   module?: any;
//   id?: number;
//   name?: string;
//   url?: string;
// }>();

// 动态组件
const DynamicComponent = ref();
const name=ref();
const [Modal, formModalApi] = useVbenModal({
  fullscreenButton: false,
  footer: false,
  onOpenChange(isOpen: boolean) {
    if (isOpen) {
      const values: { url?: string; name?: string } = formModalApi.getData();
      if (!values?.url) return;
      name.value = values.name;

      DynamicComponent.value = defineAsyncComponent(() =>
        import(`/src/views${values.url}/index.vue`)
      );
    }
  },
});
// watch(
//   () => props.url,
//   (newUrl) => {
//     console.log(props)
//     if (!newUrl) return;
    
//     DynamicComponent.value = defineAsyncComponent(() =>
//       import(`/src/views${newUrl}/index.vue`)
//     );
//   },
//   { immediate: true }
// );


</script>
<template>
  <Modal :title="name">
 
     <component :is="DynamicComponent" v-if="DynamicComponent" />
 </Modal>
</template>

